﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace University.Workshop.Presenters.CollectControl.OtherCollectControl.Read
{
    public class PresenterReadOtherCollectControl
    {
        public IReadOtherCollectControlView view;
        public Model.OtherCollectControl OtherCollect;

        public PresenterReadOtherCollectControl(IReadOtherCollectControlView view, Model.OtherCollectControl o)
        {
            this.view = view;
            OtherCollect = new Model.OtherCollectControl()
            {
                CollectId = o.CollectId,
                CollectPayDate = o.CollectPayDate,
                CollectType = o.CollectType,
                ControlDetail = o.ControlDetail,
                DateGenerated = o.DateGenerated,
                Estructura = o.Estructura,
                IsPaid = o.IsPaid,
                Kardex = o.Kardex,
                KardexId = o.KardexId,
                PaymentAmount = o.PaymentAmount,
                User = o.User,
                UserId = o.UserId
            };
        }

        public void LoadDataToView()
        { 
            view.Allotment = OtherCollect.Kardex.Allotment.First().AllotmentName;
            view.Square = OtherCollect.Kardex.Allotment.First().Square.SquareId;
            view.NamePartner = OtherCollect.Kardex.Person.Names + " " + OtherCollect.Kardex.Person.LastNames;
            view.CiPartner = OtherCollect.Kardex.Person.PersonId;
            view.ControlDetail = OtherCollect.ControlDetail;
            view.PaymentDate = OtherCollect.CollectPayDate.Value;
            view.Amount = OtherCollect.PaymentAmount;
            view.ChargeType = ((Model.OtherChargeType)OtherCollect.CollectType).ToString();
        }
    }
}
